package com.chalk.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.chalk.common.util.Result;
import com.chalk.config.base.BaseController;
import com.chalk.model.SysLookupType;
import com.chalk.service.SysLookupTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据字典(SysLookupType)表控制层
 *
 * @author maxiaoqiang
 * @since 2019-03-22 17:38:25
 */
@Api(value = "数据字典接口", tags = "数据字典模块")
@RestController
@RequestMapping("/v1/sysLookupType")
public class SysLookupTypeController extends BaseController {

    @Autowired
    private SysLookupTypeService sysLookupTypeService;


    /**
     * 获取热搜词
     *
     * @return
     */
    @ApiOperation(value = "获取热搜词列表", notes = "获取热搜词列表", response = Result.class)
    @GetMapping("/hotWord")
    public Result getHotWord() {
        return Result.success(this.sysLookupTypeService.selectList(new EntityWrapper<SysLookupType>()
                .eq("param_key", "SYSTEM_HOT_WORD").eq("is_deleted", 0).orderBy("display_order", true)));
    }


    /**
     * 获取自定义列表
     *
     * @return
     */
    @ApiOperation(value = "获取自定义列表", notes = "获取自定义列表", response = Result.class)
    @GetMapping("/customWord")
    public Result getCustomWord(@ApiParam(name = "paramKey", value = "键", required = true, example = "1") String paramKey) {
        if (StringUtils.isEmpty(paramKey)) {
            return Result.success();
        }
        return Result.success(this.sysLookupTypeService.selectList(new EntityWrapper<SysLookupType>()
                .eq("param_key", paramKey).eq("is_deleted", 0)));
    }

}